var qqcs;

$(function () {

     $("#box").height($(window).height()-$("#dddss").height()-2);

    var resultdata = $("#result").val();
    //初始化图表
    if(resultdata){
        initTb(JSON.parse(resultdata));
    }


});

//初始化图表
function initTb(result) {
    require.config({
        paths: {
            echarts: echarts2_dist_url
        }
    });

    require(
        [
            'echarts',
            'echarts/chart/pie'
        ],
        function (ec) {

            var chart1 = ec.init(document.getElementById('hs_div'));
            var chart2 = ec.init(document.getElementById('je_div'));

            window.onresize = function () {
                if (chart1) {
                    chart1.resize();
                }
                if (chart2) {
                    chart2.resize();
                }
            };

            var option1 = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{b}:<br/>共计{c}户 <br/>占比{d}%"
                },
                calculable: true,
                series: [
                    {
                        name: '企业纳税人税收级距户数情况',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '50%'],
                        data: [
                            {value: result["LSKQY_HS"],  name: '零税款企业'},
                            {value: result["SWYXQY_HS"], name: '10万以下的企业'},
                            {value: result["YBWYXQY_HS"], name: '10万-100万企业'},
                            {value: result["WBWYXQY_HS"], name: '100万-500万企业'},
                            {value: result["YQWYXQY_HS"],name: '500万-1000万企业'},
                            {value: result["WQWYXQY_HS"],name: '1000万-5000万企业'},
                            {value: result["WQWYSQY_HS"],name: '5000万以上企业户数'}
                        ]
                    }
                ]
            };
            chart1.setOption(option1);

            var option2 = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{b}:<br/>{c}万元 <br/>占比{d}%"
                },
                calculable: true,
                series: [
                    {
                        name: '企业纳税人税收级距金额情况',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%','50%'],
                        data: [
                            {value: result["LSKQY_JE"],  name: '零税款企业'},
                            {value: result["SWYXQY_JE"], name: '10万以下的企业'},
                            {value: result["YBWYXQY_JE"],name: '10万-100万企业'},
                            {value: result["WBWYXQY_JE"],name: '100万-500万企业'},
                            {value: result["YQWYXQY_JE"],name: '500万-1000万企业'},
                            {value: result["WQWYXQY_JE"],name: '1000万-5000万企业'},
                            {value: result["WQWYSQY_JE"],name: '5000万以上企业'}
                        ]
                    }
                ]
            };
            chart2.setOption(option2);

            $("input[name='dd']").click(function(){

                if(this.value==1){
                    $("#je_div").hide();
                    $("#hs_div").show();
                    if (chart1) {
                        chart1.resize();
                    }
                }else{
                    $("#hs_div").hide();
                    $("#je_div").show();
                    if (chart2) {
                        chart2.resize();
                    }
                }
            });
            $("#je_div").hide();

        }
    );
}